package com.carpedil.client.controller;

import com.carpedil.client.entity.ClientOrder;
import com.carpedil.client.movie.service.FeiginMovieService;
import com.carpedil.client.order.service.FeiginOrderService;
import com.carpedil.client.service.ClientOrderService;
import com.carpedil.client.service.impl.ClientService;
import com.carpedil.common.dto.MovieDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/** @author Administrator */
@Controller
@RequestMapping("/client")
public class ClientController {
  @Autowired FeiginOrderService feiginOrderService;
  @Autowired ClientOrderService clientOrderService;
  @Autowired FeiginMovieService feiginMovieService;
  @Autowired ClientService clientService;

  @GetMapping("/info")
  @ResponseBody
  public String getInfo() {
    String info = feiginOrderService.info();
    System.out.println("info = " + info);
    return info;
  }

  @GetMapping("/update_status/{orderId}/{code}")
  @ResponseBody
  public Integer updateOrderStatus(
      @PathVariable("orderId") String orderId, @PathVariable("code") Integer code) {
    return clientOrderService.updateStatusByOrderId(orderId, code);
  }

  @GetMapping("/booking/{id}")
  @ResponseBody
  public String booking(@PathVariable("id") Integer movieId) {
    return clientService.booking(movieId);
  }

  @GetMapping("/orders")
  @ResponseBody
  public List<ClientOrder> getOrderList() {
    return clientOrderService.getOrderList();
  }

  @GetMapping("/getMovies")
  @ResponseBody
  public List<MovieDTO> getMovieVoList() {
    System.out.println("ClientController.getMovieVoList");
    return clientService.getAllMovie();
  }

  @GetMapping({"/", "/index"})
  public String toIndex() {
    return "index";
  }
}
